const Mock = require('mockjs')

const BaseItemList=[];
for(let i=0;i<100;i++){
    BaseItemList.push(
        Mock.mock({
            id:'@increment',
            activityname:'@first',
            activitytype:'@first',
            content:'@content',
            activityprice:'@integer(10,9999)',
            dedutionmoney:'@integer(10,999)',
            guider:'@first',
            state:'@integer(0,1)',
            createtime:'@datetime'
        })
    )
}

const PackageList=[];
for(let i=0;i<10;i++){
    PackageList.push(
        Mock.mock({
            id:'@increment',
            packagename:'@first',
            activitys:[],
            state:'@integer(0,1)',
            guider:'@first',
            createtime:'@datetime'
        })
    )
    let rd=parseInt(Math.random()*3)+1;
    for(let j=0;j<rd;j++){
        PackageList[i].activitys.push(
            Mock.mock({
                baseitemid:'@increment',
                activityname:'@first',
                activitytype:'@first',
                activityprice:'@integer(1,9999)',
                dedutionmoney:'@integer(0,99)',
                count:'@integer(1,10)',
            })
        )
    } 
}

const PlanList=[];
for(let i=0;i<100;i++){
    PlanList.push(
        Mock.mock({
            id:'@increment',
            activityname:'@first',
            activitytype:'@first',
            starttime:'@datetime',
            endtime:'@datetime',
            guider:'@first',
            preamout:'@integer(99999,10000000)',
            state:'@integer(1,8)',
            createtime:'@datetime'
        })
    )
}



module.exports=[
    {
        url: '/api/activity/baseitemlist',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = BaseItemList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/activity/packagelist',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = PackageList.filter(item => {
            return true
          }) 

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/activity/planlist',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = PlanList.filter(item => {
            return true
          }) 

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
]